package com.lamdba;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class FlatMapTest {

	public static void main(String[] args) {
		Stream<String> stringStream1=Stream.of("shi yan","shi yan lou","lou yan shi");
		Stream<String> stringStream2=Stream.of("shi yan","shi yan lou","lou yan shi");
		Stream<String[]> mapStream=stringStream1.map(v->v.split(" "));
		//Stream<String> flatMapStream=stringStream2.flatMap(v-> Arrays.stream(v.split(" ")));

		List<String> flatMapStream1=stringStream2.flatMap(v-> Arrays.stream(v.split(" "))).collect(Collectors.toList());


		System.out.println("mapStream打印：");
		mapStream.peek(System.out::println).count();
		System.out.println("flatMapStream打印： ");
		//flatMapStream.peek(System.out::println).count();

		System.out.println("flatMapStream1打印： "+flatMapStream1.size());
		//flatMapStream.peek(System.out::println).count();
		flatMapStream1.forEach(System.out::println);
	}
}
